<template>
	<view class="container">
		<view class="item-head">
			<view class="item-title">
				<view></view>
				<view>{{itemDetail.repairContent === undefined ?  (itemDetail.partName === undefined ? itemDetail.repairOtherName : itemDetail.partName) : itemDetail.repairContent}}</view>
			</view>
			<view class="cancel">
				<u-icon name="close-circle-fill" color="#999999" v-if="showClose"  @click="()=>{this.$emit('deleteItem',itemDetail)}"></u-icon>
			</view>
		</view>
		<view class="item-box">
			<view class="item-details">
				<view class="item-data" v-for="(item,index) in labelList" :key="index">
					<view>{{item.label}}</view>
					<view v-if="item.type !== 'number'" @click="changePartType(item.label)">
						{{$utils.eliminate(itemDetail[item.model])}}
						<u-icon v-if="item.label === '维修类别' || item.label === '是否委外'" name="arrow-right" color="#999999" size="28"></u-icon>
					</view>
					<view v-if="item.type === 'number' && showClose">
						<u-number-box v-model="itemDetail['partQty']" :min="0" :positive-integer="false" @change="valChange"></u-number-box>
					</view>
				</view>				
			</view>
		</view>
		<!-- <u-select v-model="showType" :list="typeList" height="400rpx" @confirm="confirmType">
		</u-select> -->
	</view>
</template>

<script>		
	export default {
		props:{
			itemDetail:{type:Object,default:()=>{}},
			labelList:{type:Array,default:()=>{}},
			showClose:{type:Boolean/null,default:false}
		},
		mounted(){
			console.log('itemDetail',this.itemDetail)
		},
		methods:{
			valChange(v){
				let res = /^[0-9]+(\.\d+)?$/
				if(res.test(v.value)){
					this.$emit('getPartsNum',v.value)
				}else{
					this.$emit('getPartsNum',0)
				}
			},
			// 改变维修类型
			changePartType(val){
				if(val === '维修类别'){
					this.$emit('changePartType','1')
				}else if(val === '是否委外'){
					this.$emit('changePartType','2')
				}
			},
			
			confirmType(v){
				console.log('v:',v)
			},
		}
	}
</script>

<style lang="scss" scoped>
	.item-head{
		width: 100%;
		height: 60rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		.item-title{			
			display: flex;
			flex-direction: row;
			align-items: center;
			color: #3173cd;
			:first-child{
				width: 12rpx;
				height: 12rpx;
				background-color: #3173cd;
				border-radius: 50%;
				margin-right: 12rpx;
			}
		}
	}
	.item-box{
		.item-details{
			// dis
			.item-data{
				margin-top: 16rpx;
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				:first-child{
					color:#636363;
					font-size: 26rpx;
				}
			}
		}
	}
</style>
